-
Couldn't load subscription status.
- Fork 1.7k
feat: add GCS support as file provider (#2013) #2117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add GCS support as file provider (#2013) #2117
Conversation
|
hi @Umang01-hash , @coolwednesday , Please have a look at my PR , let me know if you notice anything that needs changes. thanks ! |
Hey! Can you add Setup details for the ease of testing and documentation for users who would want to setup the same by referring documentation (when this feature would be out). |
|
sure @coolwednesday , I will add the setup guide and documentation to help the user to use this feature. thanks for the feedback👍 |
|
hey @coolwednesday , I have noticed that the setup details for file handling (S3,FTP/SFTP etc .) are already there in Just wanted to confirm , should I add a setup instruction for GCS in the same file or would you prefer this to be in a separate file ? thanks..! |
|
Hey @coolwednesday , Could you please take a look at this above doubt ? |
|
hey @ccoVeille @Umang01-hash , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the unified handling-files documentation to include a code snippet demonstrating how to add GCS support.
Additionally, make the necessary changes in the Container package so that it works like any other datasource. For reference, review PR #2076 and replicate the relevant changes.
After that, ensure traces, logs, and metrics are integrated (also refer to #2076 for implementation details).
Once implemented:
- Add screenshots showing logs, traces, and metrics from the running cloud store.
- Add setup documentation in the docs folder.
- Update the navigation.js.
- Include any Docker container commands used in contributing.md.
|
Ok, got it. I’m working on it and will let you know once it’s completed. |
8c79d6a to
7b1824a
Compare
|
hey @Umang01-hash , @coolwednesday ,
Here are some screenshots showing logs, traces, and metrics from the running cloud store. Please let me know if you notice anything that needs changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole implementation other than this looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall rewrite of file package should be considered before adding more implementations like GCS etc
e6dcea0 to
22e4f09
Compare
|
Hi @Umang01-hash, My branch was not up to date with gofr/development. I’ve rebased it and pushed the updates now. thank you..! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please remove all the
go.modchanges from all the other datasources as they are not related to scope of your PR. Also the changes insideexamples/using-add-filestoreis also not required. Please revert all of these changes. - There are no tests written for entire newly added code but only some of it. Please make sure to write tests using mocks for the newly added code (feel free to refer other datasources to see how they use mocks for testing).
- Only export errors, constants etc when needed, unexport all the ones not used outside the directory.
|
Hi @Umang01-hash, thanks for your time.. |
22e4f09 to
690b993
Compare
|
Hi @Umang01-hash, I’ve made the required changes. Please have a look when you get a chance. thank you..! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Suryakantdsa, Thankyou for making the requested changes.
After running the tests here is your current code coverage:

Please make sure that each file (except from mocks, interfaces) has atleast 75-80% code coverage.
- Also in the example you provided in the documentation, the gcs Config:
&gcs.Config{
BucketName: "my-bucket",
CredentialsJSON: readFile("gcs-credentials.json"),
ProjectID: "my-project-id",
}Endpoint field is missing from here.
|
@Suryakantdsa are you still working on this PR?? |
|
Hi @Umang01-hash, |
|
Hi @Umang01-hash, I have addressed the required changes. thanks ! |
|
@Suryakantdsa Thankyou for all the changes, the PR looks good now. Only the retry part is left for which i have created another issue since it can be handled in other PR. |
|
@Umang01-hash I see few areas of improvement:
|
|
@akshat-kumar-singhal Thanks for your valuable feedback and review. Let's try and address these comments one by one: 1. WriteAt, ReadAt etc are implemented as "Not Supported" - why do we need to have them unless we're embedding the ReaderAt/WriterAt interfaces in our interface and hence need to mandatorily implement it.
which embeds io.ReaderAt, io.Seeker, and io.WriterAt. By implementing them with error returns, we maintain interface compliance while clearly indicating these operations aren't supported by GCS. 2. The metrics we're exposing has location i.e. file path as label value - hope we've considered the cardinality aspect here.
3. Metrics being exposed across AWS/GCP (and other providers later) should be consistent - consider having a single implementation in the main file package and restrict only the file transfer implementation in the respective packages. A unified metric set with a label for storage type (AWS/GCP/FTP etc) would allow a better visibility to the application developer as well as limit the number of new metrics/panels that'd be added. 4. We could look at the entire file system implementation as file operations + storage/retrieval, where the file operations are majorly common and can be implemented in the file package. The retrieval/storage is what can be implemented in the respective packages by FTP/SFTP/S3/GCS etc. Those implementations can have the additional check of version key/locking before updating the file on remote to ensure consistent writes.
5. Separate FileLog for GCS could be avoided - it should be available in the file package itself.
6. Definition of standard constants like SUCCESS, ERROR looks off - I understand that "Little copying is better than little dependency", we could however have these in the file package, which we'd already be importing in the various implementations
7. Definition of histogram buckets within the implementation package should be avoided.
I have created this issue #2433 where we mentioned all these changes you suggested to imrpvoe the file package implementation, once we get GCS merged then before adding any new file store our core focus will be to refactor the current implementation for all file stores. |
|
@Suryakantdsa @akshat-kumar-singhal An update here is I have made some changes to how metrics and logs are being handled by diff file systems :
GCS implementation is now using these common components. You can check these in new PR : #2435. I think now we can review and merge that and the next set of things to refactor in the file systems will be:
The current changes have significantly improved code organization while maintaining compatibility with existing implementations. After merging this PR, we can focus on the deeper architectural refactoring in a separate PR to ensure proper separation of concerns and standardization across all storage providers. |
|
@Suryakantdsa One thing that can be resolved is: These methods (Seek, ReadAt, WriteAt) should be fully implemented for the GCS provider rather than returning "not supported" errors. While GCS (like S3) doesn't natively support random access operations, we can implement these methods using similar patterns to the S3 implementation:
This would provide a consistent API across storage providers and allow users to use these methods regardless of the underlying storage system. Please follow the S3 implementation pattern with appropriate observability using the common file.OperationObservability helper. Please proceed ahead with these changes here and i will take a update from here on the new PR #2435 . |
|
ok i will proceed with them thanks @Umang01-hash |
…dsa/gofr into feat/gcs-file-provider
|
Hi @Umang01-hash , Implemented Seek, ReadAt, and WriteAt methods for GCS provider as required changes. Thanks! |
|
@Suryakantdsa Thankyou for your contribution. Since we are now continuing the review and enhancements on the new PR #2435 I am closing this PR as of now. Will continue to target and resolve any review comments there and hope to merge this feature soon! |
|
Thanks for the update! 😊 @Umang01-hash Kinda sad to see this one closed without merging 😅, but I totally get it. |




Pull Request Template
Description:
pkg/datasource/file/gcs.Create,Remove,ReadDir,Open,StatandMakeDirusingcloud.google.com/go/storage.Checklist:
goimportandgolangci-lint.Fixes #2013